home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 242_01 / a611.h < prev    next >
Text File  |  1989-01-11  |  11KB  |  383 lines

  1. /*
  2.     HEADER:        CUG242;
  3.     TITLE:        68HC11 Cross-Assembler (Portable);
  4.     FILENAME:    A611.H;
  5.     VERSION:    0.1;
  6.     DATE:        08/27/1988;
  7.  
  8.     DESCRIPTION:     "This program lets you use your computer to assemble
  9.             code for the Motorola 68HC11 microprocessor.  The
  10.             program is written in portable C rather than BDS C.
  11.             All assembler features are supported except
  12.             relocation, linkage, and macros.";
  13.  
  14.     KEYWORDS:    Software Development, Assemblers, Cross-Assemblers,
  15.             Motorola, MC68HC11;
  16.  
  17.     SYSTEM:        CP/M-80, CP/M-86, HP-UX, MSDOS, PCDOS, QNIX;
  18.     COMPILERS:    Aztec C86, Aztec CII, CI-C86, Eco-C, Eco-C88, HP-UX,
  19.             Lattice C, Microsoft C,    QNIX C;
  20.  
  21.     WARNINGS:    "This program has compiled successfully on 2 UNIX
  22.             compilers, 5 MSDOS compilers, and 2 CP/M compilers.
  23.             A port to BDS C would be extremely difficult.  A port
  24.             to Toolworks C is untried."
  25.  
  26.     AUTHORS:    William C. Colley III;
  27. */
  28.  
  29. /*
  30.              68HC11 Cross-Assembler in Portable C
  31.  
  32.         Copyright (c) 1985,1987 William C. Colley, III
  33.  
  34. Revision History:
  35.  
  36. Ver    Date        Description
  37.  
  38. 0.0    JUN 1987    Adapted from version 0.2 of the portable 6805 cross-
  39.             assembler.  WCC3.
  40.  
  41. 0.1    AUG 1988    Fixed a bug in the command line parser that puts it
  42.             into a VERY long loop if the user types a command line
  43.             like "A611 FILE.ASM -L".  WCC3 per Alex Cameron.
  44.  
  45. This header file contains the global constants and data type definitions for
  46. all modules of the cross-assembler.  This also seems a good place to put the
  47. compilation and linkage instructions for the animal.  This list currently
  48. includes the following compilers:
  49.  
  50.         Compiler Name        Op. Sys.    Processor
  51.  
  52.     1)  Aztec C86            CP/M-86        8086, 8088
  53.                     MSDOS/PCDOS
  54.  
  55.     2)  AZTEC C II            CP/M-80        8080, Z-80
  56.  
  57.     3)  Computer Innovations C86    MSDOS/PCDOS    8086, 8088
  58.  
  59.     4)  Eco-C            CP/M-80        Z-80
  60.  
  61.     5)  Eco-C88            MSDOS/PCDOS    8086, 8088
  62.  
  63.     6)  HP C            HP-UX        68000
  64.  
  65.     7)  Lattice C            MSDOS/PCDOS    8086, 8088
  66.  
  67.     8)  Microsoft C            MSDOS/PCDOS    8086, 8088
  68.  
  69.     9)  QNIX C            QNIX        8086, 8088
  70.  
  71. Further additions will be made to the list as users feed the information to
  72. me.  This particularly applies to UNIX and IBM-PC compilers.
  73.  
  74. Compile-assemble-link instructions for this program under various compilers
  75. and operating systems:
  76.  
  77.     1)    Aztec C86:
  78.  
  79.     A)  Uncomment out the "#define AZTEC_C" line and comment out all other
  80.         compiler names in A611.H.
  81.  
  82.     B)  Assuming that all files are on drive A:, run the following sequence
  83.         of command lines:
  84.  
  85.         A>cc a611
  86.         A>cc a611eval
  87.         A>cc a611util
  88.         A>ln a611.o a611eval.o a611util.o -lc
  89.         A>era a611*.o
  90.  
  91.     2)  Aztec CII (version 1.06B):
  92.  
  93.     A)  Uncomment out the "#define AZTEC_C" line and comment out all other
  94.         compiler names in A611.H.
  95.  
  96.     B)  Assuming the C compiler is called "CC.COM" and all files are
  97.         on drive A:, run the following sequence of command lines:
  98.  
  99.         A>cc a611
  100.         A>as -zap a611
  101.         A>cc a611eval
  102.         A>as -zap a611eval
  103.         A>cc a611util
  104.         A>as -zap a611util
  105.         A>ln a611.o a611eval.o a611util.o -lc
  106.         A>era a611*.o
  107.  
  108.     3)  Computer Innovations C86:
  109.  
  110.     A)  Uncomment out the "#define CI_C86" line and comment out all other
  111.         compiler names in A611.H.
  112.  
  113.     B)  Compile the files A611.C, A611EVAL.C, and A611UTIL.C.  Link
  114.         according to instructions that come with the compiler.
  115.  
  116.     4)  Eco-C (CP/M-80 version 3.10):
  117.  
  118.     A)  Uncomment out the "#define ECO_C" line and comment out all other
  119.         compiler names in A611.H.
  120.  
  121.     B)  Assuming all files are on drive A:, run the following sequence of
  122.         command lines:
  123.  
  124.         A>cp a611 -i -m
  125.         A>cp a611eval -i -m
  126.         A>cp a611util -i -m
  127.         A>l80 a611,a611eval,a611util,a611/n/e
  128.         A>era a611*.mac
  129.         A>era a611*.rel
  130.  
  131.     5)  Eco-C88:
  132.  
  133.     A)  Uncomment out the "#define ECO_C" line and comment out all other
  134.         compiler names in A611.H.
  135.  
  136.     B)  Compile the files A611.C, A611EVAL.C, and A611UTIL.C.  Link
  137.         according to instructions that come with the compiler.
  138.  
  139.     6)  HP-UX (a UNIX look-alike running on an HP-9000 Series 200/500,
  140.     68000-based machine):
  141.  
  142.     A)  Uncomment out the "#define HP_UX" line and comment out all other
  143.         compiler names in A611.H.
  144.  
  145.     B)  Run the following command line:
  146.  
  147.         . cc a611.c a611eval.c a611util.c
  148.  
  149.     7)  Lattice C:
  150.  
  151.     A)  Uncomment out the "#define LATTICE_C" line and comment out all
  152.         other compiler names in A611.H.
  153.  
  154.     B)  Compile the files A611.C, A611EVAL.C, and A611UTIL.C.  Link
  155.         according to instructions that come with the compiler.
  156.  
  157.     8)  Microsoft C (version 3.00):
  158.  
  159.     A)  Uncomment out the "#define MICROSOFT_C" line and comment out all
  160.         other compiler names in A68.H.
  161.  
  162.     B)  Run the following command line:
  163.  
  164.         C>cl a611.c a611eval.c a611util.c
  165.  
  166.     9)    QNIX C:
  167.  
  168.     A)  Uncomment out the "#define QNIX" line and comment out all other
  169.         compiler names in A611.H.
  170.  
  171.     B)  Run the following command line:
  172.  
  173.         . cc a611.c a611eval.c a611util.c
  174.  
  175. Note that, under CP/M-80, you can't re-execute a core image from a previous
  176. assembly run with the "@.COM" trick.  This technique is incompatible with the
  177. Aztec CII compiler, so I didn't bother to support it at all.
  178. */
  179.  
  180. #include <stdio.h>
  181.  
  182. /*  Comment out all but the line containing the name of your compiler:    */
  183.  
  184. #define        AZTEC_C
  185. /* #define    CI_C86                            */
  186. /* #define    ECO_C                            */
  187. /* #define    HP_UX                            */
  188. /* #define    LATTICE_C                        */
  189. /* #define    MICROSOFT_C                        */
  190. /* #define    QNIX                            */
  191.  
  192. /*  Compiler dependencies:                        */
  193.  
  194. #ifdef    AZTEC_C
  195. #define    getc(f)        agetc(f)
  196. #define    putc(c,f)    aputc(c,f)
  197. #endif
  198.  
  199. #ifndef    ECO_C
  200. #define    FALSE        0
  201. #define    TRUE        (!0)
  202. #endif
  203.  
  204. #ifdef    LATTICE_C
  205. #define    void        int
  206. #endif
  207.  
  208. #ifdef    QNIX
  209. #define    fprintf        tfprintf
  210. #define    printf        tprintf
  211. #endif
  212.  
  213. /*  On 8-bit machines, the static type is as efficient as the register    */
  214. /*  type and far more efficient than the auto type.  On larger machines    */
  215. /*  such as the 8086 family, this is not necessarily the case.  To    */
  216. /*  let you experiment to see what generates the fastest, smallest code    */
  217. /*  for your machine, I have declared internal scratch variables in    */
  218. /*  functions "SCRATCH int", "SCRATCH unsigned", etc.  A SCRATCH    */
  219. /*  varible is made static below, but you might want to try register    */
  220. /*  instead.                                */
  221.  
  222. #define    SCRATCH        static
  223.  
  224. /*  A slow, but portable way of cracking an unsigned into its various    */
  225. /*  component parts:                            */
  226.  
  227. #define    clamp(u)    ((u) &= 0xffff)
  228. #define    high(u)        (((u) >> 8) & 0xff)
  229. #define    low(u)        ((u) & 0xff)
  230. #define    word(u)        ((u) & 0xffff)
  231.  
  232. /*  The longest source line the assembler can hold without exploding:    */
  233.  
  234. #define    MAXLINE        255
  235.  
  236. /*  The maximum number of source files that can be open simultaneously:    */
  237.  
  238. #define    FILES        4
  239.  
  240. /*  The fatal error messages generated by the assembler:        */
  241.  
  242. #define    ASMOPEN        "Source File Did Not Open"
  243. #define    ASMREAD        "Error Reading Source File"
  244. #define    DSKFULL        "Disk or Directory Full"
  245. #define    FLOFLOW        "File Stack Overflow"
  246. #define    HEXOPEN        "Object File Did Not Open"
  247. #define    IFOFLOW        "If Stack Overflow"
  248. #define    LSTOPEN        "Listing File Did Not Open"
  249. #define    NOASM        "No Source File Specified"
  250. #define    SYMBOLS        "Too Many Symbols"
  251.  
  252. /*  The warning messages generated by the assembler:            */
  253.  
  254. #define    BADOPT        "Illegal Option Ignored"
  255. #define    NOHEX        "-o Option Ignored -- No File Name"
  256. #define    NOLST        "-l Option Ignored -- No File Name"
  257. #define    TWOASM        "Extra Source File Ignored"
  258. #define    TWOHEX        "Extra Object File Ignored"
  259. #define    TWOLST        "Extra Listing File Ignored"
  260.  
  261. /*  Line assembler (A611.C) constants:                    */
  262.  
  263. #define    BIGINST        5        /*  longest instruction length    */
  264. #define    IFDEPTH        16        /*  maximum IF nesting level    */
  265. #define    NOP        0x01        /*  processor's NOP opcode    */
  266. #define    ON        1        /*  assembly turned on        */
  267. #define    OFF        -1        /*  assembly turned off        */
  268.  
  269. /*  Line assembler (A611.C) opcode attribute word flag masks:        */
  270.  
  271. #define    PSEUDO        0x8000    /*  is pseudo op            */
  272. #define    ISIF        0x4000    /*  is IF, ELSE, or ENDI        */
  273. #define    REL        0x0100    /*  has relative address operand    */
  274. #define    MASK        0x0080    /*  has bit mask operand        */
  275. #define    IMM_16        0x0040    /*  immediate operands are words    */
  276. #define    IMMED        0x0020    /*  ca